{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import math\n",
    "import numpy as np\n",
    "import pylab as pl"
   ]
  },
  {
   "cell_type": "markdown",
   "source": [
    "# 最小二乘法"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "outputs": [],
   "source": [
    "def phi_k(x,k):\n",
    "    return pow(x,k)\n",
    "\n",
    "\n",
    "def squar_least(x,y,w,n):\n",
    "    G=np.zeros((n+1,n+1))\n",
    "    d=np.zeros((n+1))\n",
    "    for i in range(n+1):\n",
    "        for j in range(n+1):\n",
    "            G[i,j]=sum((w*phi_k(x,i))*phi_k(x,j))\n",
    "    \n",
    "    for i in range(n+1):\n",
    "        d[i]=sum((w*phi_k(x,i)*y))\n",
    "        \n",
    "    return np.dot(np.linalg.inv(G),d)\n",
    "    "
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(9,) (9,) (9,)\n"
     ]
    }
   ],
   "source": [
    "x=np.array([1,4,9,16,25,36,49,64,81])\n",
    "y=np.array([1,2,3.1,3.95,5.01,6,6.97,8,9.02])\n",
    "w=np.array([1,1,1,1,1,1,1,1,1])\n",
    "print(x.shape,y.shape,w.shape)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "outputs": [],
   "source": [
    "a=squar_least(x,y,w,2)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x=2.5 f(x)= 1.7376157294785475\n",
      "x=40 f(x)= 6.444116797479468\n"
     ]
    }
   ],
   "source": [
    "ans1=a[0]*1+a[1]*2.5+a[2]*pow(2.5,2)\n",
    "print(\"x=2.5 f(x)=\",ans1)\n",
    "ans2=a[0]*1+a[1]*40+a[2]*pow(40,2)\n",
    "print(\"x=40 f(x)=\",ans2)\n",
    "\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "outputs": [
    {
     "data": {
      "text/plain": "[<matplotlib.lines.Line2D at 0x208280adea0>]"
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWoAAAD4CAYAAADFAawfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAiTElEQVR4nO3deXyU1b3H8c8veyBAWIKQQNgNqxCIiFi1LhUVF2prK71Yd2yrV20tVqzXLveqbWmr1qu1uNQFd0TcRatttQtLIEAQCEtYE5awDCRkQjIz5/6RwAUFMsFMnsnM9/165RXyzDB8j0m+r8czz3OOOecQEZHoleB1ABEROTYVtYhIlFNRi4hEORW1iEiUU1GLiES5pEi8aJcuXVzv3r0j8dIiIjFp4cKFO5xzWUd6LCJF3bt3bwoLCyPx0iIiMcnMNhztMU19iIhEORW1iEiUU1GLiEQ5FbWISJRTUYuIRLmIXPUhInLA7KIyps0podznJzsznSnj8piQn+N1rFYlrDNqM7vVzJaZ2WdmdluEM4lIjJhdVMbUWcWU+fw4oMznZ+qsYmYXlXkdrVVptKjNbChwAzAaGA5cZGYDIh1MRFq/aXNK8NcFDzvmrwsybU6JR4lap3CmPgYBc51z1QBm9nfg68BvIhlMRFq/cp+/Sce/DH9tkMqaOir3B6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P3cdE5xzU51zPZxzvan/vn7snJtEbI95K7DJzPIaDp0DLCeGx0z9lMcYM2vT8HN+DvVvoMbymA842hjfBK4ws1Qz6wMMAOYf17/g9cT8IRPtFwKrgLXAT73OE6ExfoX6//VZCixu+LgQ6Ez9m22rGz538jprhMb/Vf7/zcSYHjMwAihs+F7PBjrGwZh/AawElgHPAamxNmbgRern4OuoP2O+7lhjBH7a0GklwAXH++/qFnIRkSgXLVMfIiJyFCpqEZEop6IWEYlyKmoRkSinohYRiXIqahGRKKeiFhGJcv8HoNLUWRe2xuAAAAAASUVORK5CYII=\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "xxx=[]\n",
    "yyy=[]\n",
    "for i in range(0,1000):\n",
    "    xxx.append(i/10)\n",
    "    yyy.append(a[0]*1+a[1]*i/10+a[2]*i/10*i/10)\n",
    "\n",
    "pl.scatter(x,y)\n",
    "pl.plot(xxx,yyy)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "outputs": [
    {
     "data": {
      "text/plain": "[<matplotlib.lines.Line2D at 0x2082810a140>]"
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD8CAYAAABuHP8oAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAgc0lEQVR4nO3dd3xV9f3H8dfXhIQEAiGQsEOYCQnIioC4AWWjbdW6d+lUayut1FqCuLFVHMXipM72p1aDkSkqKooyVMiCsELCSBgZZI/v74/ENiBByL03N+fe9/Px4EHuySXn8yXcNyfnns/5GGstIiLiPKd5uwAREWkaBbiIi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+zTGBSU/erTkwREYdywikUERE5DgW4iIhDKcBFRBxKAS4i4lAKcBERh1KAi4g4lAJcRMShFOAiIg71/9HbM1b2DHCcAAAAAElFTkSuQmCC\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "a=squar_least(x,y,w,1)\n",
    "xxx=[]\n",
    "yyy=[]\n",
    "for i in range(0,1000):\n",
    "    xxx.append(i/10)\n",
    "    yyy.append(a[0]*1+a[1]*i/10)\n",
    "\n",
    "pl.scatter(x,y)\n",
    "pl.plot(xxx,yyy)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "# 拉格朗日"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "outputs": [],
   "source": [
    "def lagelangri(x,y,ans_x):\n",
    "    ans_y=0\n",
    "    for i_y in range(len(y)):\n",
    "        temp=1\n",
    "        for i_x in range(len(x)):\n",
    "            if i_x!=i_y :\n",
    "                temp*=(ans_x-x[i_x])/(x[i_y]-x[i_x])\n",
    "        ans_y+=y[i_y]*temp\n",
    "    return ans_y"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x=2.5 f(x)= 1.5296665994020477\n",
      "x=40 f(x)= 6.199927388682746\n"
     ]
    }
   ],
   "source": [
    "print(\"x=2.5 f(x)=\",lagelangri(x,y,2.5))\n",
    "print(\"x=40 f(x)=\",lagelangri(x,y,40))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "outputs": [
    {
     "data": {
      "text/plain": "[<matplotlib.lines.Line2D at 0x2082816d6c0>]"
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAbsElEQVR4nO3dfWxdd53n8ffX9vWzHduxnQenaZI2TZuWbQNpp0yZ0iVAWUC0zAht0TKbRay6u2JnGDQLame1QjOziErMjkAaZqQuhYnEk6pS0Q7DQkNKmSnDtDj0OWmaNs+OY18/P17fp+/+cY9dJ7HbxPfh3Hv8eUnVPffch/P1afLxL9/zO+eYuyMiItFSFXYBIiJSeAp3EZEIUriLiESQwl1EJIIU7iIiEVQTdgEAnZ2dvmXLlrDLEBGpKAcPHhxy966lXiuLcN+yZQu9vb1hlyEiUlHM7ORyr6ktIyISQQp3EZEIUriLiESQwl1EJIIU7iIiEaRwFxGJIIW7iEgEKdxFRELyraeP848v9hfluxXuIiIh+fa/HOfnhweK8t0KdxGRkIxOp2hvrC3KdyvcRURCMJfOMDWXpqMpVpTvV7iLiIRgbCYFQHuTRu4iIpExOpMEoENtGRGR6BiZzoV7m8JdRCQ6RqdzbZkOtWVERKJjJGjLtOuAqohIdIwGbRlNhRQRiZCR6SQt9TXEqosTwwp3EZEQjM4ki9ZvB4W7iEgoRqaTRWvJgMJdRCQUozNJ2huLczAVFO4iIqEYmUoW7exUULiLiJScuzM8naSzua5o21C4i4iU2HQyw1w6y1qN3EVEomNkKriujMJdRCQ6hqbnANSWERGJkuFg5L62WSN3EZHIGAlG7mrLiIhEyND8yL1JbRkRkcgYmU7SVFtNQ2110bbxtuFuZt8ys0Eze3nRug4z229mR4PH9kWv3W9mr5vZETO7s1iFi4hUquGpOTqK2G+HSxu5/z3woQvW3QcccPftwIHgOWa2E7gHuD74zN+aWfF+NYmIVKDh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"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "xxx=[]\n",
    "yyy=[]\n",
    "for i in range(0,900):\n",
    "    xxx.append(i/10)\n",
    "    yyy.append(lagelangri(x,y,i/10))\n",
    "\n",
    "pl.scatter(x,y)\n",
    "pl.plot(xxx,yyy)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "# 分段线性插值"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "outputs": [
    {
     "data": {
      "text/plain": "[<matplotlib.lines.Line2D at 0x208291ad4b0>]"
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWoAAAD4CAYAAADFAawfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAeVklEQVR4nO3deXxU1f3/8dfJvhASIGFJSAhr2BQCARVwAbXgWrTutS61tVaq1Vqs2n7ro6399fcttj/tpqKo7QMXoEaqRYtW0ZKqlECQPQIJkA0ISxIIWWfO748ECxgkhEzunTvv5z+SmSF+PM68c3LuuedjrLWIiIh7hTldgIiIfDkFtYiIyymoRURcTkEtIuJyCmoREZeLCMQ3TU5OtpmZmYH41iIinrRq1aq91tqUtp4LSFBnZmaSn58fiG8tIuJJxpgdJ3pOSx8iIi6noBYRcTkFtYiIyymoRURcTkEtIuJyAdn1ISLihMUFZcxZWkh5VR2pSbHMnp7FzOw0p8s6bQpqEfGExQVlPJy7jromHwBlVXU8nLsOIOjDWksfIuIJc5YWfh7SR9Q1+ZiztNChijqPglpEgt76smrKqurafK78BI8HEy19iEhQ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LgB+aK293BjTixAdC2PMWFourEYBRcDttEy0QnU8fgZcT8tuqQLgW0A3PDoerglqERFpm1uWPkRE5AQU1CIiLqegFhFxOQW1iIjLKahFRFxOQS0i4nIKahERl/v/3z1IOXOSWn0AAAAASUVORK5CYII=\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "def fenduan(x,y,ans_x):\n",
    "    ans_y=0\n",
    "    for i in range(len(x)-1):\n",
    "        if x[i]<=ans_x<=x[i+1]:\n",
    "            ans_y=y[i]*((ans_x-x[i+1])/(x[i]-x[i+1]))+y[i+1]*((ans_x-x[i])/(x[i+1]-x[i]))\n",
    "        \n",
    "    return ans_y\n",
    "\n",
    "\n",
    "\n",
    "xxx=[]\n",
    "yyy=[]\n",
    "for i in range(0,900):\n",
    "    xxx.append(i/10)\n",
    "    yyy.append(fenduan(x,y,i/10))\n",
    "\n",
    "pl.scatter(x,y)\n",
    "pl.plot(xxx,yyy)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x=2.5 f(x)= 1.5\n",
      "x=40 f(x)= 6.298461538461538\n"
     ]
    }
   ],
   "source": [
    "print(\"x=2.5 f(x)=\",fenduan(x,y,2.5))\n",
    "print(\"x=40 f(x)=\",fenduan(x,y,40))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x=2.5 sqrt= 1.5811388300841898\n",
      "x=40 sqrt= 6.324555320336759\n"
     ]
    }
   ],
   "source": [
    "print(\"x=2.5 sqrt=\",math.sqrt(2.5))\n",
    "print(\"x=40 sqrt=\",math.sqrt(40))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "outputs": [],
   "source": [
    "\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}